package com.wenlin.myproduction.ui;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import androidx.annotation.Nullable;

import com.wenlin.myproduction.R;
import com.wenlin.myproduction.base.BaseActivity;
import com.wenlin.myproduction.base.BaseSwipeActivity;
import com.wenlin.myproduction.util.ToastUtils;
import com.wenlin.myproduction.util.ValCommon;
import com.wenlin.myproduction.widget.PKProgressLayout;

import java.util.Random;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * @author 文琳
 * @Email 377979485@qq.com
 * @desc 直播PK送礼物进度条
 * @time 2023-12-27 周三 16:07
 */
public class PKLayoutActivity extends BaseSwipeActivity {
    @BindView(R.id.progress_layout)
    PKProgressLayout pkLayout;

    private Random random;
    private long plusValue;

    public static void start(BaseActivity activity) {
        Intent intent = new Intent(activity, PKLayoutActivity.class);
        if (activity != null && !activity.isDestroyed() && !activity.isFinishing())
            activity.startActivity(intent);
    }

    @Override
    public int getContentView() {
        return R.layout.activity_pk_layout;
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setTitle(ValCommon.PK_LAYOUT);
        pkLayout.setInitData(0, 0);
        random = new Random();
    }

    @OnClick({R.id.tv_left, R.id.tv_right})
    void click(View view) {
        int id = view.getId();
        if (id == R.id.tv_left) {
            plusValue = 10 + random.nextInt(90);
            ToastUtils.getInstance().showInfo("左侧+" + plusValue);
            pkLayout.addLeft(plusValue);
        } else if (id == R.id.tv_right) {
            plusValue = 10 + random.nextInt(90);
            ToastUtils.getInstance().showInfo("右侧+" + plusValue);
            pkLayout.addRight(plusValue);
        }
    }
}
